import fetch from 'common/src/utils/fetch';

/**
 * 专业列表查询
 */
export function queryMajorSupList(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/queryMajorSupList',
        method: 'POST',
        data
    });
}

/**
 * 专业新增
 */
export function addMajorSup(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/addMajorSup',
        method: 'POST',
        data
    });
}

/**
 * 专业修改
 */
export function updateMajorSup(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/updateMajorSup',
        method: 'POST',
        data
    });
}

/**
 * 专业删除
 */
export function deleteMajorSup(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/deleteMajorSup',
        method: 'POST',
        data
    });
}

/**
 * 专业信息导出
 */
export function exportMajorList(params) {
    let url = '/api/cultureservice/minorMajorSup/exportMajorList';
    let query = '?';
    for (let key in params) {
        query += key;
        query += '=';
        query += params[key];
        query += '&';
    }
    return url + query.substring(0, query.length - 1);
}

/**
 * 根据学院code查询专业
 *
 */
export function queryProfession(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/queryProfession',
        method: 'POST',
        data
    });
}

// 下载模板
export function downloadTemplate(data = {}) {
    let url = `/api/cultureservice/minorMajorSup/downloadTemplate`;
    window.open(url);
}

// 查询专业代码
export function queryMajorCode(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/getCodeSup',
        method: 'post',
        data
    });
}
// 查询辅修学科门类
export function findCategoryList() {
    return fetch({
        url: '/api/commonservice/majorOfMinstryEdu/findCategoryList',
        method: 'get'
    });
}

// 设置是否有效
export function modifyMinorMajorInfoSupIsValid(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/modifyMinorMajorInfoSupIsValid',
        method: 'post',
        data
    });
}
// 设置是否有效
export function checkMajorRepeatOnCollAndMinorGrade(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/checkMajorRepeatOnCollAndMinorGrade',
        method: 'post',
        data
    });
}

// 设置是否有效
export function copyMajorBetweenMinorGrades(data) {
    return fetch({
        url: '/api/cultureservice/minorMajorSup/copyMajorBetweenMinorGrades',
        method: 'post',
        data
    });
}

export default {
    downloadTemplate
};